package PhamVanHien;

import java.util.*;

public class BaiTap2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a, b;
		System.out.print("Nhap vao so a: ");
		//a = sc.nextDouble();
		String btt = sc.nextLine();
		if (btt.isEmpty()) {
			System.out.println("ban chua nhap gia tri cho a");
		} 
			a = Double.parseDouble(btt);// chuyen doi va gan gia tri cho a
		
		System.out.println("Nhap vao so b: ");
		//b = sc.nextDouble();
		String btt1 = sc.nextLine();
		if (btt1.isEmpty()) {
			System.out.println("ban chua nhap gia tri cho b");
		} 
			b = Double.parseDouble(btt1);// chuyen doi va gan gia tri cho b
		
		System.out.println("Moi chon: 0-cong; 1- tru; 2-nhan; 3-chia");
		String btt2 = sc.nextLine();
		if (btt2.isEmpty()) {
			System.out.println("ban chua chon phep tinh");
		} else {
			byte pt = Byte.parseByte(btt2);
			if (pt == 0) {
				System.out.println("a + b =" + (a + b));
			} else if (pt == 1) {
				System.out.println("a - b =" + (a - b));
			} else if (pt == 2) {
				System.out.println("a x b =" + (a * b));
			} else {
				if (a!=0&&b==0) {
					System.out.println("Cannot divide by zero");
				}
				else if(a==0&&b==0){
					System.out.println("Result of function is underfined");
				}
				else
					System.out.println("a : b =" + (a / b));
			}
		}
	}
}
